Skip to content

fix(server): report cut-off /v1/responses replies as incomplete - #360

Open
pcbeingused333 wants to merge 1 commit into
OpenCSGs:mainfrom
pcbeingused333:fix/responses-incomplete-status
Open

pcbeingused333 wants to merge 1 commit into
OpenCSGs:mainfrom
pcbeingused333:fix/responses-incomplete-status

Conversation

@pcbeingused333

Copy link
Copy Markdown
Contributor

When the backend stops a reply early (finish_reason length or content_filter), POST /v1/responses still answers "status": "completed", and the stream ends with response.completed. A client cannot tell a truncated answer, or truncated tool call arguments, from a full one.

Cause: buildResponsesToolResponse receives a hardcoded "completed", writeResponsesToolStream hardcodes both the status and the final event, and neither reads finish_reason.

Fix: both paths now follow the Responses API shape for a cut-off reply:

  • status: "incomplete"
  • incomplete_details.reason: max_output_tokens for length, content_filter otherwise
  • the stream ends with response.incomplete instead of response.completed

Replies that finish with stop or tool_calls are unchanged. The status of the individual output items is also unchanged. The fallback branch for engines without ChatCompletionProxier is not touched, since it gets no finish reason.

Test: TestResponsesReportsCutOffReplyAsIncomplete covers both builders; its length and content_filter cases fail without the change. go test ./internal/server -run Responses passes.

This change was prepared with AI assistance (Claude Code).

The Responses handlers ignored the backend finish_reason and always
answered with status "completed". A reply stopped by the token limit or
a content filter now has status "incomplete" with incomplete_details,
and the stream ends with response.incomplete.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant